* Reset settings and initialize log file
launch, path("share/motivation")

*-------------------------------------------------------------------------------
* Price and Wasserman (2024), "The Summer Drop in Female Employment"
*
* Description: Plot BLS series on n.s.a. prime-age LFPR by gender
*-------------------------------------------------------------------------------


* Prepare time-series data on prime-age LFPR
*-------------------------------------------------------------------------------

if "$estimate" != "0" {
	* Load the BLS Labor Force Statistics
	import delimited using "$basepath/data/raw/bls/ln.data.1.AllData", delimiters("\t") clear

	* Retain prime-age (25-54) female and male LFPR
	keep if inlist(strtrim(series_id), "LNU01300061", "LNU01300062")
	gen byte female = (strtrim(series_id) == "LNU01300062")
	rename value lfpr
	destring lfpr, replace

	* Retain monthly data from recent years
	keep if inrange(year, 2013, 2019) & period != "M13"

	* Extract year/month
	gen int tm = ym(year, real(substr(period, 2, 2)))
	format %tm tm

	* Normalize each series to zero in December 2019
	bysort female (tm): egen lfpr0 = total(lfpr * (tm == tm(2019m12)))
	replace lfpr = round(lfpr - lfpr0, 0.1)

	* Save the plotting points
	keep female tm lfpr
	order female tm lfpr
	label variable female "Female"
	label variable tm "Year x month"
	label variable lfpr "Prime-age (25-54) LFPR"
	compress
	save "$basepath/models/motivation/motivation.dta", replace
}


* Plot prime-age female and male LFPR
*-------------------------------------------------------------------------------

* Load the plotting points
use "$basepath/models/motivation/motivation.dta", clear

* Prepare shading
gen rlow = -5.1
gen rupp = 1.1
gen tm_adj = tm - 0.5

* Plot the series
#delimit ;
twoway
	(rarea rupp rlow tm_adj if inrange(tm, ym(2013, 5.9), ym(2013, 9.1)), color($ltgs) plotregion(margin(t=0 b=0)))
	(rarea rupp rlow tm_adj if inrange(tm, ym(2014, 5.9), ym(2014, 9.1)), color($ltgs) plotregion(margin(t=0 b=0)))
	(rarea rupp rlow tm_adj if inrange(tm, ym(2015, 5.9), ym(2015, 9.1)), color($ltgs) plotregion(margin(t=0 b=0)))
	(rarea rupp rlow tm_adj if inrange(tm, ym(2016, 5.9), ym(2016, 9.1)), color($ltgs) plotregion(margin(t=0 b=0)))
	(rarea rupp rlow tm_adj if inrange(tm, ym(2017, 5.9), ym(2017, 9.1)), color($ltgs) plotregion(margin(t=0 b=0)))
	(rarea rupp rlow tm_adj if inrange(tm, ym(2018, 5.9), ym(2018, 9.1)), color($ltgs) plotregion(margin(t=0 b=0)))
	(rarea rupp rlow tm_adj if inrange(tm, ym(2019, 5.9), ym(2019, 9.1)), color($ltgs) plotregion(margin(t=0 b=0)))
	(scatteri 0 `=tm(2013m1)' 0 `=tm(2019m12)', recast(line) color(black))
	(connected lfpr tm if female == 1, color(black) msymbol($sym1) lwidth(medthick) msize(medsmall))
	(connected lfpr tm if female == 0, color(gs6) msymbol($sym2) lwidth(medium) mfcolor(white) msize(medsmall)),
	title("")
	xtitle("")
	xlabel(`=tm(2013m6) + 0.5'(12)`=tm(2019m6) + 0.5', format(%tmCCYY) noticks)
	xtick(`=tm(2012m12) + 0.5'(12)`=tm(2019m5) + 0.5', tlength(medlarge))
	yscale(range(-5.1 1.1))
	ylabel(-5(1)1)
	ytitle("Percentage points (Dec. 2019 = 0)")
	plotregion(margin(l=0 r=2 t=0 b=0))
	legend(order(9 "Women" 10 "Men"));
#delimit cr

nicepdf "$basepath/output/motivation.pdf", indirect replace

* Close the log file
unlaunch
